﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;

using MusicPlayerLib.ViewModel;

namespace NewPanda.ViewModel
{
    public class MusicViewModel :INotifyPropertyChanged
    {
        #region field
        private AudioFileViewModel currentTrack;
        private PlaylistViewModel currentPlaylist;
        private ObservableCollection<PlaylistViewModel> listOfPlaylist;
        private MediaLibraryViewModel mediaLibrary;
        #endregion //filed

        public event PropertyChangedEventHandler PropertyChanged;

        public MusicViewModel()
        {
        }


        #region Property
        public AudioFileViewModel CurrentTrack
        {
            get { return currentTrack; }
            set
            {
                currentTrack = value;
                this.Notify("CurrentTrack");
            }
        }

        public PlaylistViewModel CurrentPlaylist
        {
            get
            {
                return currentPlaylist;
            }
            set
            {
                currentPlaylist = value;
                this.Notify("CurrentPlaylist");
            }
        }

        public ObservableCollection<PlaylistViewModel> ListOfPlaylist
        {
            get
            {
                return listOfPlaylist;
            }
            set
            {
                listOfPlaylist = value;
            }
        }

        public MediaLibraryViewModel MediaLibrary
        {
            get
            {
                return mediaLibrary;
            }
            set
            {
                mediaLibrary = value;
            }
        }
        #endregion //Property

        #region Methods
        public void UpdateCurrentTrack()
        {
            this.CurrentTrack = new AudioFileViewModel(CurrentPlaylist.GetCurrentTrack());
        }


        public void Notify(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
        #endregion //Methods
    }
}
